<header id="topbar" class="">
    <div class="topbar-left">
        <ol class="breadcrumb">
            <li class="crumb-active">
                <a href="#stats/withdraw_order/">下分订单信息</a>
            </li>
        </ol>
    </div>
    <div class="topbar-right">
        <a href="#" class="btn btn-default btn-sm light fw600 ml10" id="exportData"><span class="glyphicon glyphicon-cloud-download pr5"></span>导出数据</a>
        <div class="ml15 ib va-m" id="toggle_sidemenu_r">
            <a href="#" class="pl5"> <i class="fa fa-sign-in fs22 text-primary"></i>
            </a>
        </div>
    </div>
</header>

<section id="content" class="animated fadeIn">
    <% if(items.length>0){ %>
    <div class="panel overflow">
        <table class="table table-striped fs13" id="main-list">
            <thead>
                <tr class="bg-light">
                    <th class="sortable" data-field="id">ID</th>
                    <th>商户订单号</th>
                    <th>支付宝交易流水号</th>
                    <th class="sortable" data-field="created_at">创建时间</th>
                    <th>商户ID</th>
                    <th>用户ID</th>
                    <th>通道ID</th>
                    <th class="sortable" data-field="total_fee">兑换金额</th>
                    <th class="sortable" data-field="withdraw_at">兑换时间</th>
                    <th class="sortable" data-field="status">兑换状态</th>
                    <th class="sortable" data-field="notify_status">回调状态</th>
                    <th class="sortable" data-field="notify_count">回调次数</th>
                    <th class="">刷新状态</th>
                </tr>
            </thead>
            <tbody class="admin-form">
                <% _.each(items, function(item){ %>
                    <tr data-id="<%= item.id %>" >
                        <td class=""><%= item.id %></td>
                        <td class=""><%= item.out_trade_no %></td>
                        <td class=""><%= item.third_id || '-' %></td>
                        <td class=""><%= item.created_at %></td>
                        <td class=""><a href="#op/mch/?id=<%= item.mch_id %>"><%= item.mch_id %><a></td>
                        <td class=""><%= item.user_id %></td>
                        <td class=""><a href="#op/withdraw_channel/<%= item.channel_id %>/"><%= item.channel_id %><a></td>
                        <td class=""><%= item.total_fee %></td>
                        <td class=""><%= item.withdraw_at || '-' %></td>
                        <td class=""><%= WITHDRAW_STATUS[item.status] %></td>
                        <td class=""><%= WITHDRAW_NOTIFY_STATUS[item.notify_status || 0] %></td>
                        <td class=""><%= item.notify_count %></td>
                        <td class="text-left">
                            <a href="javascript:;" data-id="<%= item.id %>" class="glyphicons glyphicons-refresh refreshStatus"></a>
                        </td>
                    </tr>
                <%
                }) %>
            </tbody>
        </table>
    </div>

    <div><div class="pull-left" id="page-tips"></div><div id="paginator"></div></div>
    <% }else{ %>
    <h4 class="text-muted">无数据</h4>
    <% } %>
</section>

<!-- Start: Right Sidebar -->
<aside id="sidebar_right" class="nano">
 <div class="sidebar_right_content nano-content">
     <div class="tab-block sidebar-block br-n">
        <ul class="nav nav-tabs tabs-border nav-justified">
            <li class="active">
                <a href="#sidebar-right-tab1" data-toggle="tab">统计数据</a>
            </li>
            <li>
                <a href="#sidebar-right-tab2" data-toggle="tab">过滤搜索</a>
            </li>
        </ul>
        <div class="tab-content br-n">
            <div id="sidebar-right-tab1" class="tab-pane active">
                <div class="p20 admin-form">
                    <% var total = 0,
                        count = 0;
                    _.each(overview, function(obj){
                    total += obj.total;
                    count += obj.count;
                    %>
                    <h5 class="title-divider text-muted mb20">
                      <%= obj.channel_name %>(<%= obj.app_id %>)<br/><span class="text-danger"> <%= obj.total %>元/<%= obj.count %>次 </span>
                    </h5>
                    <%})
                    if(overview.length > 1){%>
                      <h5 class="title-divider text-muted mb20">总计<span class="pull-right text-danger"> <%= total.toFixed(2) %>/<%= count %>次 </span> </h5>
                    <% }else if(overview.length == 0){ %>
                        <h5 class="text-muted mb20">无数据...</h5>
                    <% } %>
                </div>
            </div>
            <div id="sidebar-right-tab2" class="tab-pane">
                <div class="p20 admin-form">
                    <div class="section mb15">
                        <label for="searchId" class="field prepend-icon">
                            <input title="ID" type="text" data-field="id" id="searchId" class="gui-input" placeholder="ID" value="<%= searched.id  %>">
                            <label for="searchId" class="field-icon"><i class="fa fa-tag"></i>
                            </label>
                        </label>
                    </div>
                    <div class="section mb15">
                        <label for="searchOutTradeNo" class="field prepend-icon">
                            <input title="商户订单号" type="text" data-field="id" id="searchOutTradeNo" class="gui-input" placeholder="商户订单号" value="<%= searched.out_trade_no  %>">
                            <label for="searchOutTradeNo" class="field-icon"><i class="fa fa-tag"></i>
                            </label>
                        </label>
                    </div>
                    <div class="section mb15">
                        <label for="searchChannelId" class="field prepend-icon">
                            <input title="下分通道ID" type="text" data-field="id" id="searchChannelId" class="gui-input" placeholder="下分通道ID" value="<%= searched.channel_id  %>">
                            <label for="searchChannelId" class="field-icon"><i class="fa fa-tag"></i>
                            </label>
                        </label>
                    </div>
                    <div class="section mb15">
                        <label for="searchUserId" class="field prepend-icon">
                            <input title="用户ID" type="text" data-field="id" id="searchUserId" class="gui-input" placeholder="用户ID" value="<%= searched.user_id  %>">
                            <label for="searchUserId" class="field-icon"><i class="fa fa-tag"></i>
                            </label>
                        </label>
                    </div>
                    <div class="section mb15">
                        <label for="searchThirdId" class="field prepend-icon">
                            <input title="通道订单编号" type="text" data-field="id" id="searchThirdId" class="gui-input" placeholder="通道订单编号" value="<%= searched.third_id  %>">
                            <label for="searchThirdId" class="field-icon"><i class="fa fa-tag"></i>
                            </label>
                        </label>
                    </div>
                    <h6 class="fw400">商户编号</h6>
                    <div class="section mb15">
                        <label class="field select">
                            <select id="searchMchId" name="searchMchId" data-field="mch_id">
                                <option value="-1" <%= searched.mch_id == -1 ? 'selected' : '' %>>所有</option>
                                <% _.each(mchs, function(mch){ %>
                                    <option value="<%= mch.id %>" <%= searched.mch_id == mch.id ? 'selected' : '' %>><%= mch.name %>(<%= mch.id %>)</option>
                                <% }) %>
                            </select>
                            <i class="arrow double"></i>
                        </label>
                    </div>
                    <% var tf = searched.time_field || 'created_at',
                        title = '下单时间(点击切换)';
                        if(tf == 'updated_at')title = '到账时间(点击切换)';  %>
                    <h6 class="fw400" id="switchSearchTime"><%= title %></h6>
                    <div class="section row" id="searchCreatedAt" <%= tf == 'created_at' ? '' : 'hidden' %>>
                        <div class="col-md-6">
                                <input type="text" title="下限，包含当天" name="searchCreatedAtLower" id="searchCreatedAtLower" class="gui-input" data-type="date" value="<%= searched.created_at_lower %>">
                                </label>
                            </label>
                        </div>
                        <div class="col-md-6">
                                <input type="text" title="上限，不包括当天" name="searchCreatedAtUpper" id="searchCreatedAtUpper" class="gui-input" data-type="date" value="<%= searched.created_at_upper %>">
                                </label>
                            </label>
                        </div>
                    </div>
                    <div class="section row" id="searchUpdatedAt" <%= tf == 'updated_at' ? '' : 'hidden' %>>
                        <div class="col-md-6">
                                <input type="text" title="下限，包含当天" name="searchUpdatedAtLower" id="searchUpdatedAtLower" class="gui-input" data-type="date" value="<%= searched.updated_at_lower %>">
                                </label>
                            </label>
                        </div>
                        <div class="col-md-6">
                                <input type="text" title="上限，不包括当天" name="searchUpdatedAtUpper" id="searchUpdatedAtUpper" class="gui-input" data-type="date" value="<%= searched.updated_at_upper %>">
                                </label>
                            </label>
                        </div>
                    </div>
                    <h6 class="fw400">兑换状态</h6>
                    <div class="section mb15">
                        <label class="field select">
                            <select id="searchWithdrawStatus" name="searchWithdrawStatus" data-field="withdraw_status">
                                <option value="-1" <%= searched.withdraw_status == -1 ? 'selected' : '' %>>所有</option>
                                <% _.each(WITHDRAW_STATUS, function(v, k){%>
                                    <option value="<%= k %>" searched.withdraw_status == k ? 'selected': 0><%= v %></option>
                                <% }) %>
                            </select>
                            <i class="arrow double"></i>
                        </label>
                    </div>
                    <h6 class="fw400">回调状态</h6>
                    <div class="section mb15">
                        <label class="field select">
                            <select id="searchNotifyStatus" name="searchNotifyStatus" data-field="notify_status">
                                <option value="-1" <%= searched.notify_status == -1 ? 'selected' : '' %>>所有</option>
                                <% _.each(WITHDRAW_NOTIFY_STATUS, function(v, k){%>
                                    <option value="<%= k %>" searched.notify_status == k ? 'selected': 0><%= v %></option>
                                <% }) %>
                            </select>
                            <i class="arrow double"></i>
                        </label>
                    </div>
                    <hr class="short">

                    <button class="btn btn-default btn-block" type="button" id="search">搜索</button>

                </div>
            </div>
        </div>
     </div>
 </div>

</aside>
<!-- End: Right Sidebar -->
